package com.superpai.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.superpai.R;
import com.superpai.utils.AndroidUtils;

/**
 * @author Devin.Hu
 * @date 2011-8-13
 * @version V1.0
 * @description 更多页面
 */
public class MoreActivity extends BaseActivity {
	
	private LinearLayout more_warranty;
	private LinearLayout more_about;
	//private LinearLayout more_browse;
	//private LinearLayout more_hotline;
	private LinearLayout more_feedback;
	private LinearLayout more_sinaweibo;
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.more);
        initMenuView(this, mIndexMore);
        initViews();
	}
    
    private void initViews(){
    	title = (TextView)this.findViewById(R.id.title);
		title.setText(R.string.menu_more);
		
    	more_warranty = (LinearLayout)this.findViewById(R.id.more_warranty);
    	more_about = (LinearLayout)this.findViewById(R.id.more_about);
    	//more_browse = (LinearLayout)this.findViewById(R.id.more_browse);
    	//more_hotline = (LinearLayout)this.findViewById(R.id.more_hotline);
    	more_feedback = (LinearLayout)this.findViewById(R.id.more_feedback);
    	more_sinaweibo = (LinearLayout)this.findViewById(R.id.more_sinaweibo);
    	
    	more_warranty.setOnClickListener(this);
    	more_about.setOnClickListener(this);
    	//more_browse.setOnClickListener(this);
    	//more_hotline.setOnClickListener(this);
    	more_feedback.setOnClickListener(this);
    	more_sinaweibo.setOnClickListener(this);
    }

	@Override
	public Object doDataConnection(int type) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void doProcessData(int type, Object... values) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onClick(View v) {
		checkMenu(v);
		
		if(v == more_sinaweibo){
			AndroidUtils.sharePaiPai(mContext.getString(R.string.more_sina_info),this);
		}
		if(v == more_about){
			Intent intent = new Intent();
			intent.setClass(mContext, AboutActivity.class);
			mContext.startActivity(intent);
		}
		if(v == more_feedback){
			Intent intent = new Intent();
			intent.setClass(mContext, FeedbackActivity.class);
			mContext.startActivity(intent);
		}
		if(v == more_warranty){
			Intent intent = new Intent();
			intent.setClass(mContext, WarrantyActivity.class);
			mContext.startActivity(intent);
		}
		
//		if(v == more_hotline){
//			Intent intent = new Intent();
//			intent.setClass(mContext, HotlineActivity.class);
//			mContext.startActivity(intent);
//			AndroidUtils.pageAnimation(this);
//		}
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode == KeyEvent.KEYCODE_BACK){
			new AlertDialog.Builder(this)
			.setTitle(R.string.common_tishi)
			.setMessage(R.string.common_sys_exit)
			.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int whichButton) {
					sysExit();
				}
			})
			.setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					
				}
			})
			.show();
			return true;
		}else{
			return super.onKeyDown(keyCode, event);
		}
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		disConnection();
	}
}